package org.java;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class DoProperties {
	public static void main(String[] args) {
		Properties prop = new Properties();
		try {
			prop.load(new BufferedInputStream (new FileInputStream("config.properties")));
			System.out.println(prop.get("key1"));
			prop.put("key1", "data1");
			FileOutputStream out = new FileOutputStream(new File("config.properties"));
			prop.store(out , "comments");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	}
}
